package com.tensquare.base.controller;

import com.tensquare.base.pojo.Label;
import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*** 统一异常处理类 */
@ControllerAdvice//增强所有Controller
public class BaseExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result<Label> error(Exception e) {
        e.printStackTrace();
        return new Result<Label>(false, StatusCode.ERROR, e.getMessage());
    }
}
